<template>
  <el-card
    shadow="never"
    :body-style="{ padding: '24px 32px', height: '100%' }"
    class="cus-card">
    <div class="operation-wrapper">
      <el-button
        type="primary"
        size="small"
        icon="el-icon-plus"
        @click="$router.push({ name: 'expressCreate' })">
        新建运费模板
      </el-button>
      <div class="search-wrapper">
        <el-input
          v-model="input"
          size="small"
          style="width: 200px; margin-right: 10px"
          placeholder="按运费模版名称进行搜索">
        </el-input>
        <el-button type="primary" size="small">搜索</el-button>
      </div>
    </div>
    <div class="tabel-wrap">
      <el-table
        :data="list"
        style="width: 100%">
        <el-table-column
          prop="name"
          label="模版名称">
        </el-table-column>
        <el-table-column
          prop="updated_at"
          label="最后编辑时间"
          width="180">
        </el-table-column>
        <el-table-column
          label="操作"
          width="180">
          <template slot-scope="scope">
            <div class="tb-action">
              <el-button type="text">复制模版</el-button>
              <el-button
                type="text"
                @click="$router.push({ name: 'expressEdit', params: { id: scope.row.id } })">
                修改
              </el-button>
              <el-button type="text">删除</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </el-card>
</template>

<script>
import { getExpressTemplates } from '@/api/express'

export default {
  data () {
    return {
      list: []
    }
  },
  created() {
    this.getExpressTemplates()
  },
  methods: {
    getExpressTemplates() {
      getExpressTemplates().then(res => {
        if (res.status === 'success') {
          this.list = res.data
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.operation-wrapper {
  position: relative;
  margin-bottom: 15px;
}
.search-wrapper {
  display: inline-flex;
  position: absolute;
  right: 0;
  top: 0;
  font-size: 14px;
}
</style>